package com.example.foodapp;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

public class Advertisement extends AppCompatActivity {
    //定义控件
    TextView mTvMessage;

    private static final String TAG="Advertisement";




    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_advertisement);

        //找到控件
        mTvMessage=findViewById(R.id.tv_message);

        //倒计时
        new CountDownTimer(5000,1000){

            @Override
            public void onTick(long millisUntilFinished) {
                mTvMessage.setText((millisUntilFinished / 1000)+"s");
            }

            @Override
            public void onFinish() {
                Intent intent=new Intent(Advertisement.this,MainActivity.class);
                startActivity(intent);
                //删除原页面
                finish();
            }
        }.start();
        //获取网络图片
        showPic();
    }

    private void showPic() {
        Picasso.with(this)//设置上下文
                .load("https://tse1-mm.cn.bing.net/th/id/R-C.d24a44c17e185f0e1cc914af445140ba?rik=xrfhvAmLVuQWSA&riu=http%3a%2f%2fpic40.photophoto.cn%2f20160816%2f0042040257956376_b.jpg&ehk=2nbiodlGWhaSDo8CqK5FiZ1aNDv47p7ElifuLTtvUdk%3d&risl=&pid=ImgRaw&r=0")//加载的地址
                .into((ImageView) findViewById(R.id.iv_advertisement));//显示控件

    }





}